<template>
  <div>我是列表</div>
  <div v-for="item in data" :key="item.name">
    菜名:{{ item.name }}...价格:{{ item.price }}...<button
      @click="() => goDetail(item)"
    >
      跳转详情
    </button>
  </div>
</template>
<script setup>
import { ref } from "vue";
import { getMenuList } from "../../../services/menu.js";
import { useRouter } from "vue-router";

const data = ref([]);
const router = useRouter();
const getData = async () => {
  const res = await getMenuList();
  // console.log(res.data.data);
  data.value = res.data.data;
};
const goDetail = (item) => {
  router.push({ name: "userDetail", query: item });
};
getData();
</script>
<style></style>
